<?
/*********************************************
 *获取系统分类
 * *******************************************/
function smarty_function_qishi_get_classify($params, &$smarty)
{
	extract($params);
	global $db;
	$act = (NULL != $act) ? $act : "jobs"; //默认为职位分类
	$listname = (NULL != $listname) ? $listname : 'list'; //默认的section名称
	$titlelen = (NULL != $titlelen) ? $titlelen : 15; //文字截取长度
	$dot = (NULL != $dot) ? $dot : ''; //默认截取后填补字符
	//获取职能分类
	if ($act=="jobs")
	{
		$result = $db->query("SELECT * FROM ".table('jobs_category')." where ParentID='0' ORDER BY category_order desc,id asc");
		while($row = $db->fetch_array($result))
		{
			$row['categoryname']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$row['title']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$val[] = $row;
		}
	}
	//获取地区分类
	if ($act=="district")
	{
//		$sql = "select * from ".table('jobs_area')."  ORDER BY category_order desc,id asc";
//		$result = $db->query($sql);
//		while($row = $db->fetch_array($result))
//		{
//			$row['categoryname']=cut_str($row['categoryname'],$titlelen,0,$dot);
//			$row['title']=cut_str($row['categoryname'],$titlelen,0,$dot);
//			$val[] = $row;
//		}

		$a=array('101'=>'中區','102'=>'東區','103'=>'南區','104'=>'灣仔區','105'=>'西區');
		$b=array('201'=>'九龍城區','202'=>'觀塘區','203'=>'深水埗區','204'=>'黃大仙區','205'=>'油尖旺區');
		$c=array('301'=>'葵青區','302'=>'新界北區','303'=>'西貢區','304'=>'沙田區','305'=>'大埔區','306'=>'荃灣區','307'=>'屯門區','308'=>'元朗區');
		$d=array('401'=>'長洲區','402'=>'大嶼山區');
		
		$arr=array(
			array('100'=>'--全香港島--'),$a,
			array('200'=>'--全九龍--'),$b,
			array('300'=>'--全新界--'),$c,
			array('400'=>'--全離島--'),$d,
			array('500'=>'其他離島區'),
			array('600'=>'香港以外地區')
		);
		
		foreach($arr as $key => $value)
		{
			
			if(is_array($value)){
			foreach ($value as $k=> $area){
				$row['categoryname']=$area;			
				$row['id']=$k;
				$val[] = $row;
				}
			}
			else {
				$row['categoryname']=$value;			
				$row['id']=$key;
				$val[] = $row;
				
			}
			
		}
	}
	//获取时间范围
	if ($act=="settr")
	{
		$sql = "select * from ".table('jobs_settr')."  ORDER BY category_order desc,id asc";
		$result = $db->query($sql);
		while($row = $db->fetch_array($result))
		{
			$row['categoryname']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$row['title']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$val[] = $row;
		}
	}
	//薪资待遇分类
	if ($act=="wage")
	{
		$sql = "select * from ".table('jobs_wage')."  ORDER BY category_order desc,id asc";
		$result = $db->query($sql);
		while($row = $db->fetch_array($result))
		{
			$row['categoryname']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$row['title']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$val[] = $row;
		}
	}
	//职位性质
	if ($act=="nature")
	{
		$sql = "select * from ".table('jobs_nature')."  ORDER BY category_order desc,id asc";
		$result = $db->query($sql);
		while($row = $db->fetch_array($result))
		{
			$row['categoryname']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$row['title']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$val[] = $row;
		}
	}
	//学历划分
	if ($act=="education")
	{
		$sql = "select * from ".table('jobs_education')."  ORDER BY category_order desc,id asc";
		$result = $db->query($sql);
		while($row = $db->fetch_array($result))
		{
			$row['categoryname']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$row['title']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$val[] = $row;
		}
	}
	//工作经验
	if ($act=="experience")
	{
		$sql = "select * from ".table('jobs_experience')."  ORDER BY category_order desc,id asc";
		$result = $db->query($sql);
		while($row = $db->fetch_array($result))
		{
			$row['categoryname']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$row['title']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$val[] = $row;
		}
	}
	//公司性质
	if ($act=="corporation")
	{
		$sql = "select * from ".table('jobs_corporation')."  ORDER BY category_order desc,id asc";
		$result = $db->query($sql);
		while($row = $db->fetch_array($result))
		{
			$row['categoryname']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$row['title']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$val[] = $row;
		}
	}
	//行业分类
	if ($act=="trade")
	{
		$sql = "select * from ".table('jobs_trade')."  ORDER BY category_order desc,id asc";
		$result = $db->query($sql);
		while($row = $db->fetch_array($result))
		{
			$row['categoryname']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$row['title']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$val[] = $row;
		}
	}
	//公司规模分类
	if ($act=="scale")
	{
		$sql = "select * from ".table('jobs_scale')."  ORDER BY category_order desc,id asc";
		$result = $db->query($sql);
		while($row = $db->fetch_array($result))
		{
			$row['categoryname']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$row['title']=cut_str($row['categoryname'],$titlelen,0,$dot);
			$val[] = $row;
		}
	}
	$smarty->assign($listname, $val);
	unset($val);
}
?>